{include file="public/header" /}




<div class="page">
	<div class="fixed-bar">
		<div class="item-title">
			<div class="subject">
				<h3>数据字典</h3>
				<h5></h5>
			</div>
			{include file="public/admin_items" /}
		</div>
	</div>
	<form method="post" class="form-horizontal js-ajax-form margin-top-20" action="{:url('dictionary/save')}">
		<table class="sc-default-table">
			<tr>
				<td width="100"><span class="form-required">*</span>字典类型</td>
				<td>
					<select id="input-dict_type" class="form-control" name="dict_type">
						{foreach name="dict_types" item="item" key="key"}
						<option value="{$key}">{$item}</option>
						{/foreach}
					</select>
				</td>
			</tr>
			<tr>
				<td><span class="form-required">*</span>key</td>
				<td><input type="text" class="form-control" id="input-key" name="key" value=""></td>
			</tr>
			<tr>
				<td><span class="form-required">*</span>value</td>
				<td><input type="text" class="form-control" id="input-value" name="value" value=""></td>
			</tr>
			<tr>
				<td><span class="form-required"></span>备注</td>
				<td><input type="text" class="form-control" id="input-remark" name="remark" value=""></td>
			</tr>
			<tr>
				<td><span class="form-required"></span></td>
				<td>
					<input type="hidden" name="id" id="input-id" value="" />
					<button type="submit" class="btn btn-primary js-ajax-submit">保存</button>
					<a class="btn btn-default" href="javascript:history.back(-1);">返回</a>
				</td>
			</tr>
		</table>
	</form>
</div>

<script>
	// 表单自动填充
	{notempty name="dictionary"}
    var dictionary = {$dictionary|json_encode};

    for(var key in dictionary) {
        if(key === 'dict_type') {
            $('#input-dict_type').val([dictionary[key]]);
        } else {
            $('#input-'+key).val(dictionary[key]);
        }
    }
	{/notempty}
</script>
</body>
</html>